﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Engine2D
{
    public struct SceneVertex : IVertexType
    {
        Vector3 mPosition;
        Vector3 mNormal;
        Vector3 mColor;
        Vector2 mUV;

        public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
        (
            new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
            new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
            new VertexElement(24, VertexElementFormat.Vector3, VertexElementUsage.Color, 0),
            new VertexElement(36, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
        );

        public SceneVertex(Vector3 position, Vector3 normal, Vector3 color, Vector2 uv)
        {
            mPosition = position;
            mNormal = normal;
            mColor = color;
            mUV = uv;
        }

        public Vector3 Position
        {
            get { return mPosition; }
            set { mPosition = value; }
        }

        public Vector3 Normal
        {
            get { return mNormal; }
            set { mNormal = value; }
        }

        public Vector3 Color
        {
            get { return mColor; }
            set { mColor = value; }
        }

        public Vector2 UV
        {
            get { return mUV; }
            set { mUV = value; }
        }

        VertexDeclaration IVertexType.VertexDeclaration
        {
            get { return VertexDeclaration; }
        }
    }
}
